home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
cgraphix
/
kdrawtxt.c
< prev
next >
Wrap
Text File
|
1986-05-08
|
3KB
|
128 lines
/* «RM120»«PL99999»«TS4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76» */
#include <stdio.h>
#define EXTERN extern
#include <typedef.h>
void DrawAscii(x, y, size, ch)
int *x, *y, size, ch;
{
int x1ref,x2ref,xpos,ypos,xstart,ystart,xend,yend,xx,yy;
unsigned char CharByte;
unsigned mask;
x1ref = X1RefGlb * 8;
x2ref = (X2RefGlb * 8) + 7;
for (ypos = 0; ypos <= 5; ypos++) {
CharByte=(CharSet[3*(ch-32)+2-(int)(ypos/2)]>>((ypos%2)? 4:0))&0x0f;
mask = 8;
for (xpos = 0; xpos <= 3; xpos++) {
if (CharByte & mask) { /* is a pixel to plot */
xstart = (*x) + xpos * size;
xend = xstart + size - 1;
ystart = (*y) + 1 + (ypos - 2) * size;
yend = ystart + size - 1;
if (ClippingGlb) {
if (xstart < x1ref)
xstart = x1ref;
if (xend > x2ref)
xend = x2ref;
if (ystart < Y1RefGlb)
ystart = Y1RefGlb;
if (yend>Y2RefGlb)
yend = Y2RefGlb;
}
for (yy = ystart; yy <= yend; yy++)
for (xx = xstart; xx <= xend; xx++)
DP(xx,yy);
}
mask = mask >> 1;
}
}
*x = *x + 6 * size;
}
void DrawText(x, y, scale, txt)
int x, y, scale;
char *txt;
{
int LineStyleLoc, code, AsciiValue, StringLen, i;
int SymbolScale, SymbolCode;
int DirectModeLoc;
DirectModeLoc = DirectModeGlb;
DirectModeGlb = TRUE;
LineStyleLoc = LineStyleGlb;
SetLineStyle(0);
StringLen = strlen(txt);
i = 0;
while (i < StringLen) {
AsciiValue = txt[i];
if (AsciiValue == 27) {
SymbolScale = scale;
i = i+1;
if (i <= StringLen) {
SymbolCode = txt[i] - '0';
if ((i+2 <= StringLen) && (txt[i+1] == 64)) {
SymbolScale = txt[i+2] - '0';
i = i + 2;
}
switch (SymbolCode) {
case 1:
DrawCross(x+SymbolScale,y+scale,SymbolScale);
break;
case 2:
DrawCrossDiag(x+SymbolScale,y+scale,SymbolScale);
break;
case 3:
case 4:
DrawSquareC(x, y + (SymbolScale * 2) - 1,
x + (SymbolScale * 2), y - 1, (SymbolCode == 4));
break;
case 5:
DrawDiamond(x + (int)(1.5 * SymbolScale),
y + SymbolScale - 1, SymbolScale + 1);
x = x + SymbolScale;
break;
case 6:
DrawWye(x + SymbolScale, y + SymbolScale - 1,
SymbolScale);
break;
case 7:
DrawStar(x+SymbolScale * 2, y + SymbolScale - 1,
SymbolScale);
x = x + SymbolScale * 2;
break;
case 8:
DrawCircleDirect(x+SymbolScale,y+(SymbolScale >> 1),
SymbolScale+1,FALSE);
break;
}
x = x + 3 * SymbolScale;
SymbolScale = scale;
}
}
else
DrawAscii(&x, &y, scale, AsciiValue);
i = i+1;
}
DirectModeGlb = DirectModeLoc;
SetLineStyle(LineStyleLoc);
}
void DrawTextW(x, y, scale, txt)
double x, y;
int scale;
char *txt;
{
if (DirectModeGlb)
DrawText((int)x, (int)y, scale, txt);
else
DrawText(WindowX(x), WindowY(y), scale, txt);
}